package com.yang.testrequest;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.util.Arrays;

@WebServlet("/sr01")
public class ServletRequest01 extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        StringBuffer requestURL = req.getRequestURL();
        System.out.println(requestURL);
        String requestURI = req.getRequestURI();
        System.out.println(requestURI);
        String queryString = req.getQueryString();
        System.out.println(queryString);
        String method = req.getMethod();
        System.out.println(method);
        String protocol = req.getProtocol();
        System.out.println(protocol);
        String contextPath = req.getContextPath();
        System.out.println(contextPath);
        System.out.println("----------------------------------------------");
        String uname = req.getParameter("uname");
        System.out.println("指定的uname"+uname);
        String password = req.getParameter("password");
        System.out.println("指定的password"+password);
        String[] hobbies = req.getParameterValues("hobby");
        System.out.println("<UNK>hobby"+ Arrays.toString(hobbies));
    }
}
